class Result {
  constructor(code, message, data) {
    this.code = code;
    this.message = message;
    if (data !== undefined && data) this.data = data;
  }

  static success(data, message = "操作成功", code = 200) {
    return new Result(code, message, data);
  }

  static fail(message = "操作失败", code = 500) {
    return new Result(code, message, null);
  }
}

module.exports = Result;
